package com.dalianbank.config;

import com.dalianbank.controller.IndexPortal;
import com.dalianbank.controller.MainController;
import com.dalianbank.controller.SerchController;
import com.dalianbank.pojo.AllTables;
import com.dalianbank.pojo.AllUser;
import com.dalianbank.pojo.DV;
import com.dalianbank.pojo.DVEO;
import com.dalianbank.pojo.DataType;
import com.dalianbank.pojo.GzhdCpResult;
import com.dalianbank.pojo.TV;
import com.dalianbank.pojo.TVEO;
import com.dalianbank.pojo.UI;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
import com.jfinal.plugin.activerecord.dialect.OracleDialect;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;

public class AppConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		PropKit.use("configuration.properties");
		me.setDevMode(true);
		me.setViewType(ViewType.FREE_MARKER);
	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configPlugin(Plugins me) {
		C3p0Plugin cp=new C3p0Plugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password").trim());
		cp.setDriverClass(PropKit.get("jdbcDriver"));
		me.add(cp);
		
		ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);
		me.add(arp);
		arp.setDialect(new OracleDialect());
		arp.setContainerFactory(new CaseInsensitiveContainerFactory());
//		arp.addMapping("gz.F_DOWNLODCFG", FDownlodCfg.class);
//		arp.addMapping("gz.f_structurecfg",FStructurecfg.class);
//		arp.addMapping("all_users",AllUser.class);
//		arp.addMapping("all_tables",AllTables.class);
//		arp.addMapping("gz0716.tv",TV.class);
		arp.addMapping("vp.UI",UI.class);
		arp.addMapping("vp.DV", DV.class);
		arp.addMapping("vp.TV", TV.class);
		arp.addMapping("vp.DV_EO", DVEO.class);
		arp.addMapping("vp.TV_EO", TVEO.class);
		arp.addMapping("vp.Data_Type", DataType.class);
		arp.addMapping("user_tables", AllTables.class);
		
	//	arp.addMapping("vp.GZHD_CP_RESULT", GzhdCpResult.class);
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/index", IndexPortal.class,"/index");
	//	me.add("/cptool", AppController.class,"/cptool");
		me.add("/search",SerchController.class);
		me.add("/main",MainController.class,"/main");
	}
	
}
